package com.yu.shaungxuan.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.shaungxuan.model.common.Result;
import com.yu.shaungxuan.model.dto.TeacherLoginInfo;
import com.yu.shaungxuan.model.entity.Student;
import com.yu.shaungxuan.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api(tags = "老师相关接口")
@RequestMapping("/teacher")
public class TeacherController {

    @Resource
    private TeacherService teacherService;

    @PostMapping("/login")
    @ApiOperation("老师登录")
    public Result<String> login(@RequestBody TeacherLoginInfo teacherLoginInfo){
        return teacherService.login(teacherLoginInfo);
    }

    @GetMapping("/showAll")
    @ApiOperation("老师显示所有选择他的学生")
    public Result<Page<Student>> showAllStudents(Integer page, Integer pageSize){
        return teacherService.show(page,pageSize);
    }

    @GetMapping("/receive/{id}")
    @ApiOperation("老师接受")
    public Result<String> receive(@PathVariable("id") Long id){
        return teacherService.receive(id);
    }


    @PutMapping("/receive/{id}")
    @ApiOperation("老师拒绝")
    public Result<String> reject(@PathVariable("id") Long id){
        return teacherService.reject(id);
    }




}
